package crystal.workshop.ui;

import java.beans.PropertyChangeListener;
import java.util.Map;

import crystal.lib.Crystal;

/**
 * Interface for using structure data in a Model-View-Controller pattern.  This
 * interface defined the minimum set of functionality expected from a structure
 * data model.
 * By using the MVC pattern we can decouple the model from the delegate i.e.
 * user interface.
 *
 * @author Martin Uhrin
 *
 */
public interface StructureDataModel {
	
	/**
	 * The name of the structure as given by the source from where it was
	 * loaded e.g. the filename for structures loaded from disk. 
	 * @return
	 */
	public String getSourceName();
	
	/**
	 * Get the custom name given to the structure, if no custom name exists a
	 * default name should be provided.
	 * @return the custom name for this structure or a default name if no
	 * custom name has been given.
	 */
	public String getCustomName();
	
	/**
	 * Set the custom name for this structure.
	 * @param name the custom name
	 */
	public void setCustomName( final String name );
	
	/**
	 * Get the crystal structure for this structure object.
	 * @return the crystal structure
	 */
	public Crystal getCrystal();
	
	/**
	 * Set the crystal for this structure object.
	 * @return the old crystal or null if none exists
	 */
	public Crystal setCrystal(final Crystal c);
	
	/**
	 * Get a map of all the properties for this structure.
	 * @return all the structure properties.
	 */
	public Map<String, Object> getProperties();
	
	/**
	 * Add a custom property to this crystal structure.
	 * @param propName the property name
	 * @param property the property instance
	 */
	public void addProperty(final String propName, final Object property);
	
	/**
	 * Remove a property from this structure.
	 * @param propName the property name to remove
	 * @return the property instance that has been remove, or null if not found
	 */
	public Object removeProperty(final String propName);
	
	/**
	 * Updates an existing property to a new value.
	 * @param propName the name of the existing property
	 * @param property the new value for the property
	 */
	//public void updateProperty(final String propName, final Object property);
	// TODO: Implement above later
	
	/**
	 * Get a custom property of this structure.
	 * @param propName the property name to retrieve
	 * @return the property instance or null if not found
	 */
	public Object getProperty(final String propName);
	
	public void addPropertyChangeListener(final PropertyChangeListener listener);
	
	public void removePropertyChangeListener(final PropertyChangeListener listener);
}
